"use strict";

$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
function post(url,data,callback,that,callbackErr=null,load=true) {
    let loading=null;
    if (load){
        loading = that.$loading({
            lock: true,
            text: '请求中...',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
        });
    }

    $.ajax({
        type : "POST",
        url : url,
        data:data,
        success : function(res){
            if (load && loading) loading.close();
            if (res.err>0){
                alert(res.msg);
            }else{
                callback(res);
            }
        },
        error:function (err) {
            if (callbackErr){
                callbackErr(res);
            }
        }
    });
}

function get(url,data,callback,that,callbackErr=null,load=true) {
    let loading=null;
    if (load){
        loading = that.$loading({
            lock: true,
            text: '请求中...',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
        });
    }

    $.ajax({
        type : "GET",
        url : url,
        data:data,
        success : function(res){
            if (load && loading) loading.close();
            if (res.err>0){
                alert(res.msg);
            }else{
                callback(res);
            }
        },
        error:function (err) {
            if (callbackErr){
                callbackErr(res);
            }
        }
    });
}

function getLocalTime(nS) {
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
}

function windowShow(url,title){
    layer.open({
        title:title,
        type: 2,
        area: ['95%', '95%'],
        content: url //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
    });
}

function loading() {
    const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
    });
}

function GetQueryString(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return unescape(r[2]); return 0;
}

function ChrRaces($index) {
    switch ($index) {
        case 1:
            return "人类";
        case 2:
            return "兽人";
        case 4:
            return "暗夜精灵";
        case 5:
            return "亡灵";
        case 7:
            return "侏儒";
        case 6:
            return "牛头人";
        case 64:
            return "Gnome";
        case 8:
            return "巨魔";
        case 256:
            return "哥布林";
        case 10:
            return "血精灵";
        case 11:
            return "德莱尼";
        case 3:
            return "矮人";
        default:
            return "未知种族"+$index;
    }
}

function GetClass($index)
{
    switch ($index)
    {
        case 1:
            return "战士";
        case 2:
            return "圣骑士";
        case 3:
            return "猎人";
        case 4:
            return "潜行者";
        case 8:
            return "法师";
        case 5:
            return "牧师";
        case 6:
            return "死亡骑士";
        case 11:
            return "德鲁伊";
        case 9:
            return "术士";
        case 7:
            return "萨满";
        default:
            return "未知职业"+$index;
    }
}

$(document).ready(
    function () {
        $('#app').attr('style','display: block;');
    }
);




var _hmt = _hmt || [];
(function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?56702062dbd44e9733ea18cae889c455";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();

let itemClass=[
    {
        value: '0', label: '可消费的', children: [
            { value: '0_', label: '全部' },
            { value: '0_0', label: '消耗品' },
            { value: '0_1', label: '药水' },
            { value: '0_2', label: '战斗药剂' },
            { value: '0_3', label: '守护药剂' },
            { value: '0_4', label: '卷轴' },
            { value: '0_5', label: '食物和饮料' },
            { value: '0_6', label: '物品强化' },
            { value: '0_7', label: '绷带' },
            { value: '0_8', label: '其他' },
        ]
    },
    {
        value: '1', label: '容器', children: [
            { value: '1_', label: '全部' },
            { value: '1_0', label: '背包' },
            { value: '1_1', label: '灵魂袋' },
            { value: '1_2', label: '草药袋' },
            { value: '1_3', label: '附魔袋' },
            { value: '1_4', label: '工程袋' },
            { value: '1_5', label: '宝石袋' },
            { value: '1_6', label: '矿石袋' },
            { value: '1_7', label: '皮革袋' },
            { value: '1_8', label: '铭文包' },
        ]
    },
    {
        value: '2', label: '武器', children: [
            { value: '2_', label: '全部' },
            { value: '2_0', label: '单手斧' },
            { value: '2_1', label: '双手斧' },
            { value: '2_4', label: '单手锤' },
            { value: '2_5', label: '双手锤' },
            { value: '2_6', label: '长柄武器' },
            { value: '2_7', label: '单手剑' },
            { value: '2_8', label: '双手剑' },
            { value: '2_10', label: '法杖' },
            { value: '2_15', label: '匕首' },
            { value: '2_13', label: '拳套' },
            { value: '2_2', label: '弓' },
            { value: '2_3', label: '枪械' },
            { value: '2_18', label: '弩' },
            { value: '2_19', label: '魔杖' },
            { value: '2_16', label: '投掷武器' },
            { value: '2_20', label: '鱼竿' },
            { value: '2_17', label: '矛' },
            { value: '2_9', label: '过时的' },
            { value: '2_11', label: 'Exotic' },
            { value: '2_12', label: 'Exotic' },
            { value: '2_14', label: '其他(铁匠锤、采矿镐等)' },
        ]
    },
    {
        value: '3', label: '宝石', children: [
            { value: '3_', label: '全部' },
            { value: '3_7', label: '简易' },
            { value: '3_0', label: '红' },
            { value: '3_1', label: '蓝' },
            { value: '3_2', label: '黄' },
            { value: '3_3', label: '紫：红/蓝' },
            { value: '3_4', label: '绿：黄/蓝' },
            { value: '3_5', label: '橙：黄/红' },
            { value: '3_8', label: '多彩：红/黄/蓝' },
            { value: '3_6', label: '钻石' },
        ]
    },
    {
        value: '4', label: '护甲', children: [
            { value: '4_', label: '全部' },
            { value: '4_0', label: '杂项' },
            { value: '4_1', label: '布甲' },
            { value: '4_2', label: '皮甲' },
            { value: '4_3', label: '锁甲' },
            { value: '4_4', label: '板甲' },
            { value: '4_5', label: '防御物', comment: 'OBSOLETE' },
            { value: '4_6', label: '盾' },
            { value: '4_7', label: 'Libram' },
            { value: '4_8', label: '雕像' },
            { value: '4_9', label: '图腾' },
            { value: '4_10', label: '印章' },
        ]
    },
    {
        value: '5', label: '药剂', children: [
            { value: '5_0', label: '药剂' }
        ]
    },
    {
        value: '6', label: '弹药', children: [
            { value: '6_', label: '全部' },
            { value: '6_0', label: 'Wand', comment: 'OBSOLETE' },
            { value: '6_1', label: '螺栓', comment: 'OBSOLETE' },
            { value: '6_2', label: '箭头' },
            { value: '6_3', label: '子弹' },
            { value: '6_4', label: '投掷', comment: 'OBSOLETE' },
        ]
    },
    {
        value: '7', label: '商品', children: [
            { value: '7_', label: '全部' },
            { value: '7_0', label: '商品' },
            { value: '7_1', label: '部分' },
            { value: '7_2', label: '炸药' },
            { value: '7_3', label: '设备' },
            { value: '7_4', label: '珠宝加工' },
            { value: '7_5', label: '布' },
            { value: '7_6', label: '皮革' },
            { value: '7_7', label: '金属和石头' },
            { value: '7_8', label: '肉' },
            { value: '7_9', label: '草药' },
            { value: '7_10', label: '元素' },
            { value: '7_11', label: '其他' },
            { value: '7_12', label: '附魔' },
            { value: '7_13', label: '材料' },
            { value: '7_14', label: '防具附魔' },
            { value: '7_15', label: '武器附魔' },
        ]
    },
    {
        value: '8', label: '通用(过时的)', children: [
            { value: '8_0', label: 'Generic', comment: 'OBSOLETE' }
        ]
    },
    {
        value: '9', label: '配方', children: [
            { value: '9_', label: '全部' },
            { value: '9_0', label: '书' },
            { value: '9_1', label: '制皮' },
            { value: '9_2', label: '裁剪' },
            { value: '9_3', label: '工程' },
            { value: '9_4', label: '锻造' },
            { value: '9_5', label: '烹饪' },
            { value: '9_6', label: '炼金' },
            { value: '9_7', label: '急救' },
            { value: '9_8', label: '附魔' },
            { value: '9_9', label: '钓鱼' },
            { value: '9_10', label: '珠宝加工' },
        ]
    },
    {
        value: '10', label: '钱(过时的)', children: [
            { value: '10_0', label: 'Money', comment: 'OBSOLETE' }
        ]
    },
    {
        value: '11', label: '箭袋', children: [
            { value: '11_', label: '全部' },
            { value: '11_0', label: 'Quiver (OBSOLETE)' },
            { value: '11_1', label: 'Quiver (OBSOLETE)' },
            { value: '11_2', label: '箭袋', comment: '(Can hold arrows)' },
            { value: '11_3', label: '弹药袋', comment: 'Can hold bullets' },
        ]
    },
    {
        value: '12', label: '任务', children: [
            { value: '12_0', label: '任务' }
        ]
    },
    {
        value: '13', label: '钥匙', children: [
            { value: '13_', label: '全部' },
            { value: '13_0', label: '钥匙' },
            { value: '13_1', label: '开锁工具' },
        ]
    },
    {
        value: '14', label: '永久(过时的)', children: [
            { value: '14_0', label: '永久的 Permanent' }
        ]
    },
    {
        value: '15', label: '杂项', children: [
            { value: '15_', label: '全部' },
            { value: '15_0', label: '垃圾' },
            { value: '15_1', label: '试剂' },
            { value: '15_2', label: '宠物' },
            { value: '15_3', label: '假期' },
            { value: '15_4', label: '其他' },
            { value: '15_5', label: '坐骑' },]
    },
    {
        value: '16', label: '雕文', children: [
            { value: '16_', label: '全部' },
            { value: '16_1', label: '战士' },
            { value: '16_2', label: '圣骑士' },
            { value: '16_3', label: '猎人' },
            { value: '16_4', label: '盗贼' },
            { value: '16_5', label: '牧师' },
            { value: '16_6', label: '死亡骑士' },
            { value: '16_7', label: '萨满' },
            { value: '16_8', label: '法师' },
            { value: '16_9', label: '术士' },
            { value: '16_11', label: '德鲁伊' },
        ]
    },
];
